home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
DEV
/
A-B
/
606+gest.cpt
/
Sound.p
< prev
next >
Wrap
Text File
|
1990-10-17
|
14KB
|
503 lines
{ This file has been processed by The THINK Pascal Source Converter, v1.1. }
{}
{ Copyright © Symantec Corporation 1990}
{ Copyright Apple Computer, Inc. 1985-1990}
{ All rights reserved.}
{}
{ 6.0.6 Sound interface}
{}
{ Converted from the 6.0.6 beta 19 interfaces 10/17/90 -MYG}
unit Sound;
interface
const
synthCodeRsrc = 'snth';
soundListRsrc = 'snd ';
{ synthesizer numbers for SndNewChannel }
noteSynth = 1; {note synthesizer}
waveTableSynth = 3; {wave table synthesizer}
sampledSynth = 5; {sampled sound synthesizer}
{ Param2 values }
twelthRootTwo = 1.05946309434;
infiniteTime = $7FFFFFFF;
{ command numbers for SndDoCommand }
nullCmd = 0;
initCmd = 1;
freeCmd = 2;
quietCmd = 3;
flushCmd = 4;
reInitCmd = 5;
waitCmd = 10;
pauseCmd = 11;
resumeCmd = 12;
callBackCmd = 13;
syncCmd = 14;
emptyCmd = 15;
tickleCmd = 20;
requestNextCmd = 21;
howOftenCmd = 22;
wakeUpCmd = 23;
availableCmd = 24;
versionCmd = 25;
totalLoadCmd = 26;
loadCmd = 27;
scaleCmd = 30;
tempoCmd = 31;
noteCmd = 40;
restCmd = 41;
freqCmd = 42;
ampCmd = 43;
timbreCmd = 44;
waveTableCmd = 60;
phaseCmd = 61;
soundCmd = 80;
bufferCmd = 81;
rateCmd = 82;
continueCmd = 83;
doubleBufferCmd = 84;
getRateCmd = 85;
sizeCmd = 90;
convertCmd = 91;
stdQLength = 128;
dataPointerFlag = $8000;
waveInitChannelMask = 7;
waveInitChannel0 = 4; {channel 0 - wave table only}
waveInitChannel1 = 5; {channel 1 - wave table only}
waveInitChannel2 = 6; {channel 2 - wave table only}
waveInitChannel3 = 7; {channel 3 - wave table only}
initSRateMask = 48;
initStereoMask = 192;
initChanLeft = 2; {left stereo channel }
initChanRight = 3; {right stereo channel}
initSRate22k = 32; {22k sampling rate}
initMono = 128; {monophonic channel}
initStereo = 192; {stereo channel}
initNoInterp = 4;
initNoSRC = 8;
initNoMultiChannel = 4096;
initMACE3 = 768;
initMACE6 = 1024;
stdSH = $00;
extSH = $FF;
cmpSH = $FE;
notCompressed = 0;
twoToOne = 1;
eightToThree = 2;
threeToOne = 3;
sixToOne = 4;
outsideCmpSH = 0;
insideCmpSH = 1;
aceSuccess = 0;
aceMemFull = 1;
aceNilBlock = 2;
aceBadComp = 3;
aceBadEncode = 4;
aceBadDest = 5;
aceBadCmd = 6;
sixToOnePacketSize = 8;
threeToOnePacketSize = 16;
stateBlockSize = 64;
stateBlockSizeMinusOne = Stateblocksize - 1;
leftOverBlockSize = 32;
leftOverBlockSizeMinusOne = LeftOverBlockSize - 1;
firstSoundFormat = 1;
secondSoundFormat = 2;
sysBeepDisable = $0000;
sysBeepEnable = $0001;
{ unitTypes for AudioSelection.unitType }
unitTypeNoSelection = $FFFF;
unitTypeSeconds = $0000;
dbBufferEmpty = $00000000;
dbBufferEmptyMask = $FFFFFFFE;
dbBufferReady = $00000001;
dbBufferExhausted = $00000002;
dbLastBuffer = $00000004;
{ errors codes for Sound Manager 7.0 }
notEnoughBufferSpace = -207; { could not allocate enough memory }
badFileFormat = -208; { was not type AIFF or was of bad format,corrupt }
channelBusy = -209; { the Channel is being used for a PFD already }
buffersTooSmall = -210; { can not operate in the memory allowed }
channelNotBusy = -211;
noMoreRealTime = -212; { not enought CPU cycles left to add another task }
badParam = -213; { invalid argument }
{ constants for MACE in the dispatcher }
MACEToolNum = 16;
sMgrMACEVersion = 0;
sMgrComp3to1 = 4;
sMgrExp1to3 = 8;
sMgrComp6to1 = 12;
sMgrExp1to6 = 16;
{ constants for Sound Manager Extensions in the dispatcher }
sMgrToolNum = 8;
sMgrSndStartFilePlay = (13 * 256) + 0;
sMgrSndPauseFilePlay = (2 * 256) + 4;
sMgrSndStopFilePlay = (3 * 256) + 8;
sMgrSndSoundManagerVersion = 12;
sMgrSndChannelStatus = 16;
sMgrSndManagerStatus = 20;
sMgrSndGetSysBeepState = 24;
sMgrSndSetSysBeepState = 28;
sMgrSndPlayDoubleBuffer = 32;
sMgrSndGetBufferStufferLoad = 36;
sMgrSndGetMixerLoad = 40;
type
FreeWave = packed array[0..30000] of Byte;
FFSynthPtr = ^FFSynthRec;
FFSynthRec = record
mode: INTEGER;
count: Fixed;
waveBytes: FreeWave;
end;
Tone = record
count: INTEGER;
amplitude: INTEGER;
duration: INTEGER;
end;
Tones = array[0..5000] of Tone;
SWSynthPtr = ^SWSynthRec;
SWSynthRec = record
mode: INTEGER;
triplets: Tones;
end;
Wave = packed array[0..255] of Byte;
WavePtr = ^Wave;
FTSndRecPtr = ^FTSoundRec;
FTSoundRec = record
duration: INTEGER;
sound1Rate: Fixed;
sound1Phase: LONGINT;
sound2Rate: Fixed;
sound2Phase: LONGINT;
sound3Rate: Fixed;
sound3Phase: LONGINT;
sound4Rate: Fixed;
sound4Phase: LONGINT;
sound1Wave: WavePtr;
sound2Wave: WavePtr;
sound3Wave: WavePtr;
sound4Wave: WavePtr;
end;
FTSynthPtr = ^FTSynthRec;
FTSynthRec = record
mode: INTEGER;
sndRec: FTSndRecPtr;
end;
SndCommand = packed record
cmd: INTEGER;
param1: INTEGER;
param2: LONGINT;
end;
Time = LONGINT;
ModifierStubPtr = ^ModifierStub;
ModifierStub = packed record
nextStub: ModifierStubPtr;
code: ProcPtr;
userInfo: LONGINT;
count: Time;
every: Time;
flags: SignedByte;
hState: SignedByte;
end;
SndChannelPtr = ^SndChannel;
SndChannel = packed record
nextChan: SndChannelPtr;
firstMod: ModifierStubPtr;
callBack: ProcPtr;
userInfo: LONGINT;
wait: Time; {The following is for internal Sound Manager use only.}
cmdInProgress: SndCommand;
flags: INTEGER;
qLength: INTEGER;
qHead: INTEGER; {next spot to read or -1 if empty}
qTail: INTEGER; {next spot to write = qHead if full}
queue: array[0..127] of SndCommand;
end;
SoundHeaderPtr = ^SoundHeader;
SoundHeader = packed record
samplePtr: Ptr; {if NIL then samples are in sampleArea}
length: LONGINT;
sampleRate: Fixed;
loopStart: LONGINT;
loopEnd: LONGINT;
encode: Byte;
baseNote: Byte;
sampleArea: array[0..0] of Byte;
end;
ModRef = record
modNumber: INTEGER;
modInit: LONGINT;
end;
{ ••• MACE typedef structures ••• }
StateBlockPtr = ^StateBlock;
StateBlock = record
stateVar: array[0..stateBlockSizeMinusOne] of INTEGER;
end;
LeftOverBlockPtr = ^LeftOverBlock;
LeftOverBlock = record
count: INTEGER;
sampleArea: array[0..leftOverBlockSizeMinusOne] of INTEGER;
end;
CmpSoundHeaderPtr = ^CmpSoundHeader;
CmpSoundHeader = packed record
samplePtr: Ptr; {if NIL then samples are in sampleArea}
numChannels: LONGINT; { AIFC, number of channels mono = 1 }
sampleRate: Fixed; { sample rate in Apples Fixed point representation }
loopStart: LONGINT; { loopStart of sound before compression }
loopEnd: LONGINT; { loopEnd of sound before compression }
encode: Byte; { data structure used , stdSH, extSH, or cmpSH }
baseNote: Byte; { same meaning as regular SoundHeader }
numSampleFrames: LONGINT; { length in frames ( packetFrames or sampleFrames }
AIFFSampleRate: EXTENDED; { AIFC, IEEE sample rate }
MarkerChunk: Ptr; { AIFC, sync track }
FutureUse1: Ptr; { reserved by Apple }
FutureUse2: Ptr; { reserved by Apple }
StateVars: StateBlockPtr; { pointer to State Block }
LeftOverSamples: LeftOverBlockPtr; { used to save truncated samples between compression calls }
compressionID: INTEGER; { 0 means no compression, non zero means compressionID }
packetSize: INTEGER; { AIFC, number of bits in compressed sample packet }
snthID: INTEGER; { Resource ID of Sound Manager snth that contains NRT C/E }
sampleSize: INTEGER; { AIFC, number of bits in non-compressed sample }
sampleArea: array[0..0] of Byte; { space for when samples follow directly }
end;
ExtSoundHeaderPtr = ^ExtSoundHeader;
ExtSoundHeader = packed record
samplePtr: Ptr; {if NIL then samples are in sampleArea}
numChannels: LONGINT; { AIFF, number of channels mono = 1 }
sampleRate: Fixed; { sample rate in Apples Fixed point representation }
loopStart: LONGINT; { loopStart of sound before compression }
loopEnd: LONGINT; { loopEnd of sound before compression }
encode: Byte; { data structure used , stdSH, extSH, or cmpSH }
baseNote: Byte; { same meaning as regular SoundHeader }
numSampleFrames: LONGINT; { length in total number of frames }
AIFFSampleRate: EXTENDED; { AIFF, IEEE sample rate }
MarkerChunk: Ptr; { AIFF, sync track }
InstrumentChunks: Ptr;
AESRecording: Ptr;
sampleSize: INTEGER; { AIFF, number of bits in sample }
FutureUse1: INTEGER; { reserved by Apple }
FutureUse2: LONGINT; { reserved by Apple }
FutureUse3: LONGINT; { reserved by Apple }
FutureUse4: LONGINT; { reserved by Apple }
sampleArea: array[0..0] of Byte; { space for when samples follow directly }
end;
SMStatusPtr = ^SMStatus;
SMStatus = record
smMaxCPULoad: INTEGER;
smNumChannels: INTEGER;
smCurCPULoad: INTEGER;
end;
SCStatusPtr = ^SCStatus;
SCStatus = record
scStartTime: Fixed;
scEndTime: Fixed;
scCurrentTime: Fixed;
scChannelBusy: BOOLEAN;
scChannelDisposed: BOOLEAN;
scChannelPaused: BOOLEAN;
scUnused: INTEGER;
scChannelAttributes: LONGINT;
scCPULoad: LONGINT;
end;
SndDoubleBufferPtr = ^SndDoubleBuffer;
SndDoubleBuffer = record
dbNumFrames: LONGINT;
dbFlags: LONGINT;
dbUserInfo: array[0..1] of LONGINT;
dbSoundData: array[0..0] of INTEGER;
end;
AudioSelectionPtr = ^AudioSelection;
AudioSelection = record
unitType: LONGINT;
selStart: Fixed;
selEnd: Fixed;
end;
SndDoubleBufferHeaderPtr = ^SndDoubleBufferHeader;
SndDoubleBufferHeader = record
dbhNumChannels: INTEGER;
dbhSampleSize: INTEGER;
dbhCompressionID: INTEGER;
dbhPacketSize: INTEGER;
dbhBufferPtr: array[0..1] of SndDoubleBufferPtr;
dbhDoubleBack: ProcPtr;
end;
SndListPtr = ^SndListResource;
SndListResource = record
format: INTEGER;
numModifiers: INTEGER;
modifierPart: array[0..0] of ModRef;
numCommands: INTEGER;
commandPart: array[0..0] of SndCommand;
dataPart: packed array[0..0] of Byte;
end;
{ ••• Trap Call Definitions ••• }
function SndDoCommand (chan: SndChannelPtr; cmd: SndCommand; noWait: BOOLEAN): OSErr;
inline
$A803;
function SndDoImmediate (chan: SndChannelPtr; cmd: SndCommand): OSErr;
inline
$A804;
function SndNewChannel (var chan: SndChannelPtr; synth: INTEGER; init: LONGINT; userRoutine: ProcPtr): OSErr;
inline
$A807;
function SndDisposeChannel (chan: SndChannelPtr; quietNow: BOOLEAN): OSErr;
inline
$A801;
function SndPlay (chan: SndChannelPtr; sndHdl: Handle; async: BOOLEAN): OSErr;
inline
$A805;
function SndControl (id: INTEGER; var cmd: SndCommand): OSErr;
inline
$A806;
procedure SetSoundVol (level: INTEGER);
procedure GetSoundVol (var level: INTEGER);
procedure StartSound (synthRec: Ptr; numBytes: LONGINT; completionRtn: ProcPtr);
procedure StopSound;
function SoundDone: BOOLEAN;
function SndAddModifier (chan: SndChannelPtr; modifier: ProcPtr; id: INTEGER; init: LONGINT): OSErr;
inline
$A802;
{ Sound Manager Extension calls - a future Glue Library will replace these }
function SndSoundManagerVersion: LONGINT;
inline
$203C, sMgrSndSoundManagerVersion, sMgrToolNum, $A800;
function SndStartFilePlay (theChannel: SndChannelPtr; fRefNum: INTEGER; resNum: INTEGER; totalSpace: LONGINT; TheBuffer: Ptr; theSelection: AudioSelectionPtr; completionRtn: ProcPtr; async: BOOLEAN): OSErr;
inline
$203C, sMgrSndStartFilePlay, sMgrToolNum, $A800;
function SndPauseFilePlay (theChannel: SndChannelPtr): OSErr;
inline
$203C, sMgrSndPauseFilePlay, sMgrToolNum, $A800;
function SndStopFilePlay (theChannel: SndChannelPtr; async: BOOLEAN): OSErr;
inline
$203C, sMgrSndStopFilePlay, sMgrToolNum, $A800;
function SndChannelStatus (theChannel: SndChannelPtr; theLength: INTEGER; theStatus: SCStatusPtr): OSErr;
inline
$203C, sMgrSndChannelStatus, sMgrToolNum, $A800;
function SndManagerStatus (theLength: INTEGER; theStatus: SCStatusPtr): OSErr;
inline
$203C, sMgrSndManagerStatus, sMgrToolNum, $A800;
function SndGetSysBeepState (var sysBeepState: INTEGER): OSErr;
inline
$203C, sMgrSndGetSysBeepState, sMgrToolNum, $A800;
function SndSetSysBeepState (sysBeepState: INTEGER): OSErr;
inline
$203C, sMgrSndSetSysBeepState, sMgrToolNum, $A800;
function SndPlayDoubleBuffer (theChannel: SndChannelPtr; theParams: SndDoubleBufferHeaderPtr): OSErr;
inline
$203C, sMgrSndPlayDoubleBuffer, sMgrToolNum, $A800;
function SndGetBufferStufferLoad (channelFeatures: INTEGER): INTEGER;
inline
$203C, sMgrSndGetBufferStufferLoad, sMgrToolNum, $A800;
function SndGetMixerLoad (numChannels: INTEGER): INTEGER;
inline
$203C, sMgrSndGetMixerLoad, sMgrToolNum, $A800;
function MACEVersion: LONGINT;
inline
$203C, sMgrMACEVersion, MACEToolNum, $A800;
procedure Comp3to1 (inBuffer: Ptr; outBuffer: Ptr; Cnt: LONGINT; inState: Ptr; outState: Ptr; numChannels: LONGINT; whichChannel: LONGINT);
inline
$203C, sMgrComp3to1, MACEToolNum, $A800;
procedure Comp6to1 (inBuffer: Ptr; outBuffer: Ptr; Cnt: LONGINT; inState: Ptr; outState: Ptr; numChannels: LONGINT; whichChannel: LONGINT);
inline
$203C, sMgrComp6to1, MACEToolNum, $A800;
procedure Exp1to3 (inBuffer: Ptr; outBuffer: Ptr; Cnt: LONGINT; inState: Ptr; outState: Ptr; numChannels: LONGINT; whichChannel: LONGINT);
inline
$203C, sMgrExp1to3, MACEToolNum, $A800;
procedure Exp1to6 (inBuffer: Ptr; outBuffer: Ptr; Cnt: LONGINT; inState: Ptr; outState: Ptr; numChannels: LONGINT; whichChannel: LONGINT);
inline
$203C, sMgrExp1to6, MACEToolNum, $A800;
{ UsingSound }
implementation
end.